<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑生成代码模板信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="returnIndex()"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <button class="btn btn-info" id="save" onclick="SystemTemplateInfoMgr.submitForm()" type="button"><i
                      class="fa fa-save">&nbsp;&nbsp;</i>保存
              </button>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>生成代码模板信息</strong>
          </div>
          <form action="/systemTemplateInfo/saveSystemTemplateInfo" class="form-horizontal" id="systemTemplateInfoForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input class="form-control" id="id" name="id" type="hidden" value="${systemTemplateInfo.id!}">
            <div class="form-group">
              <label class="col-sm-2 control-label">模板编码：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templateCode" name="templateCode" required="required"
                       type="text"
                       value="${systemTemplateInfo.templateCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">模板名称：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templateName" name="templateName" required="required"
                       type="text"
                       value="${systemTemplateInfo.templateName!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">java模板路径：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templateJavaPath" name="templateJavaPath"
                       required="required" type="text"
                       value="${systemTemplateInfo.templateJavaPath!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">页面模板路径：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templatePagePath" name="templatePagePath"
                       required="required" type="text"
                       value="${systemTemplateInfo.templatePagePath!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">xml模板路径：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templateXmlPath" name="templateXmlPath"
                       required="required" type="text"
                       value="${systemTemplateInfo.templateXmlPath!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">备注：</label>
              <div class="col-sm-8">
                <input class="form-control" id="templateComment" name="templateComment"
                       required="required" type="text"
                       value="${systemTemplateInfo.templateComment!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group" id="templateModuleDiv">
              <label class="col-sm-2 control-label"></label>
              <button class="btn btn-info col-sm-2" id="addTemplateModule"
                      onclick="SystemTemplateInfoMgr.addTemplateModule()"
                      type="button"><i class="fa fa-plus">&nbsp;&nbsp;</i>新增模板模块信息
              </button>
            </div>
            <div class="h-msg-title h-table-header">
              <strong>生成模板模块信息</strong>
            </div>
            <div class="form-group" style="width:800px;margin-left:180px">
              <table class="table-bordered table-hover text-center dataTable no-footer">
                <thead>
                <tr role="row">
                  <td>序号</td>
                  <td>模块编码</td>
                  <td>模块名称</td>
                  <td>文件输出绝对路径</td>
                  <td>操作</td>
                </tr>
                </thead>
                <tbody>
                <#assign i=1>
                <#list systemTemplateModuleInfoList as stm>
                <tr>
                  <td>${i}</td>
                  <td class="text-left">${stm.templateModuleCode!}</td>
                  <td class="text-left">${stm.templateModuleName!}</td>
                  <td class="text-left">${stm.outputFolder!}</td>
                  <td>
                    <#if operation !='view'>
                    <a href="javascript:void(0);"
                       onclick="SystemTemplateInfoMgr.updateTemplateModule('${stm.id!}')">修改</a>
                    <a href="javascript:void(0);"
                       onclick="SystemTemplateInfoMgr.deleteTemplateModule('${stm.id!}')">删除</a>
                  </#if>
                  </td>
                </tr>
                <#assign i=i+1>
                </#list>
                </tbody>
              </table>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>

<#include "/common/jslib.html">
<!-- 弹窗下拉 -->
<script type="text/javascript">
    function returnIndex() {
        window.location.href = "/systemTemplateInfo/query";
    }

    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        // 弹出窗体控制
        SystemTemplateInfoMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                }
                initDict(DICTURL, FORM, operation);
                if (operation != 'add') {
                    $("#templateModuleDiv").show();
                } else {
                    $("#templateModuleDiv").hide();
                }
            },
            // init end

            // 提交数据
            submitForm: function () {
                Jmts.ajaxSubmit(document.getElementById("systemTemplateInfoForm"), function (result) {
                    if (result.success) {
                        if (operation == 'add') {
                            Jmts.succTips(result.msg);
                            window.location.href = "/systemTemplateInfo/to-form?operation=edit&id=" +
                                result.resultData.id;
                        } else {
                            Jmts.succTips(result.msg);
                            window.location.reload();
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            returnIndex: function () {
                window.location.href = "/systemTemplateInfo/query";
            },
            //添加模板模块信息
            addTemplateModule: function () {
                var templateId = $("#id").val();
                var url = "/systemTemplateModuleInfo/to-form?operation=add&templateId=" + templateId;
                Jmts.openDialog("systemTemplateModuleAddId", url, "添加模板模块信息", 600, 1000, 32);
            },
            updateTemplateModule: function (id) {
                var url = "/systemTemplateModuleInfo/to-form?operation=edit&id=" + id;
                Jmts.openDialog("systemTemplateModuleEditId", url, "编辑模板模块信息", 600, 1200, 32);
            },
            deleteTemplateModule: function (id) {
                var url = "/systemTemplateModuleInfo/delete";
                var data = {
                    id: id
                }
                Jmts.confirm("确定要删除吗？", function () {
                    Jmts.ajaxPost(url, data, function (result) {
                        if (result.success) {
                            Jmts.succTips(result.msg);
                            window.location.reload();
                        } else {
                            Jmts.errorTips(result.msg);
                        }
                    });
                })
            }
        };
        // 执行初始化
        SystemTemplateInfoMgr.init();
        // 前台验证表单
        $("#systemTemplateInfoForm").validate();
    });
</script>
</body>
</html>
